how to find the endpoint of a line